$(function () {
    $("#recoverForm").ajaxForm(function (data) {
        if (data.success) {
            $.messager.alert("温馨提示", "还原成功", "info");
        } else {
            $.messager.alert("温馨提示", data.msg, "info");
        }
    });
    var load = $("#home").data("load");
    $("#home").click(function () {
        $("body").load(load);
    });

    sendSearchUrl($("#home"));
});

function sendSearchUrl(a) {
    console.log(a);
    var parentNodeName = $(a).closest("ul").closest("li").find("span").html();
    var childName = a.text;
    if(!parentNodeName){
        childName = '主页';
        parentNodeName = '欢迎界面';
    }
    var place = parentNodeName + " > " + childName;
    $("#contentTitle").html(place);
    var url = "/" + $(a).data("url");
    $(".side-bar").prop("display", "none");
    if ($("#myIframe").size() > 0) {
        $("#myIframe").detach();
    }
    if ($(a).data("url") == "database") {
        $("#database").prop("hidden", false);
        return;
    }

    $("#database").prop("hidden", true);
    $("#myContainer").after('<iframe id="myIframe" src="' + url + '" width="121%" frameborder=0></iframe>');
    $("#myIframe").prop("height", (document.documentElement.clientHeight - 135) + "px");
    $("#myIframe").prop("display", "block");

}

function backup() {
    window.location.href = "/database/backup.do";
}
//签到
function onState() {
    $.get("/attendance/onState.do", function (data) {
        if (data.success) {
            $.messager.alert("温馨提示", "签到成功", "info", function () {
                $("#datagrid").datagrid("reload");
            });
        } else {
            $.messager.alert("温馨提示", data.msg, "info");
        }
    })
}

//签退
function downState() {
    $.get("/attendance/downState.do", function (data) {
        if (data.success) {
            $.messager.alert("温馨提示", "签退成功", "info", function () {
                $("#datagrid").datagrid("reload");
            });
        } else {
            $.messager.alert("温馨提示", data.msg, "info");
        }
    })
}




